﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Station.Inspect.Forms
{
    static class FormDics
    {
        static Dictionary<string, Form> formDic = new Dictionary<string, Form>();
        static object lockObj = new object();

        static public Form GetForm(string name)
        {
            lock(lockObj)
            {
                Form form = null;
                formDic.TryGetValue(name, out form);
                return form;
            }
        }

        static public void AddForm(string name,Form form)
        {
            lock (lockObj)
            {
                formDic[name] = form;
            }
                
        }

        static public void RemoveForm(Form form)
        {
            lock (lockObj)
            {
                foreach (var item in formDic)
                {
                    if (item.Value == form)
                    {
                        formDic.Remove(item.Key);
                        return;
                    }
                }
            }
        }
    }
}
